package exception.Exception;

public class ExceptionDemo1 {
    public static void main(String[] args) {
        System.out.println("======");
        try {
            saveAge(2088);
        } catch (AgeIllegalException e) {
            //打印异常信息
            e.printStackTrace();
            System.out.println("失败了");
        }
        System.out.println("======");
    }

    public static void saveAge(int age) throws AgeIllegalException {
        if (age<1||age>200) {
            //年龄非法
            throw new AgeIllegalException("年龄非法");
        } else {
            System.out.println("年龄保存成功");
            System.out.println("年龄："+age);
        }
    }
}


